home *** CD-ROM | disk | FTP | other *** search
/ Team Palmtops 7 / Palmtops_numero07.iso / WinCE / SDKWindowsCE / HandHeldPCPro30 / sdk.exe / Jupiter SDK / data1.cab / Emulation_Include_Files / schnlsp.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-02-19  |  10.1 KB  |  379 lines

  1. /*++
  2.  
  3. Copyright (c) 1992-1998 Microsoft Corporation
  4.  
  5. Module Name: schnlsp.h
  6.  
  7. Purpose: Prototypes and structures for schannel security provider.
  8.  
  9. --*/
  10.  
  11. #ifndef __SCHNLSP_H__
  12. #define __SCHNLSP_H__
  13.  
  14. #include <wincrypt.h>
  15. #include <sslsock.h>
  16.  
  17. #define SSLOLD_NAME_A "Microsoft SSL"
  18. #define SSLOLD_NAME_W L"Microsoft SSL"
  19. #define PCTOLD_NAME_A "Microsoft PCT"
  20. #define PCTOLD_NAME_W L"Microsoft PCT"
  21.  
  22. #define UNISP_NAME_A    "Microsoft Unified Security Protocol Provider"
  23. #define UNISP_NAME_W    L"Microsoft Unified Security Protocol Provider"
  24.  
  25. #define SSL2SP_NAME_A    "Microsoft SSL 2.0"
  26. #define SSL2SP_NAME_W    L"Microsoft SSL 2.0"
  27.  
  28. #define SSL3SP_NAME_A    "Microsoft SSL 3.0"
  29. #define SSL3SP_NAME_W    L"Microsoft SSL 3.0"
  30.  
  31. #define PCT1SP_NAME_A    "Microsoft PCT 1.0"
  32. #define PCT1SP_NAME_W    L"Microsoft PCT 1.0"
  33.  
  34.  
  35. #ifdef UNICODE
  36. #define SSLOLD_NAME  SSLOLD_NAME_W
  37. #define PCTOLD_NAME  PCTOLD_NAME_W
  38. #define UNISP_NAME   UNISP_NAME_W
  39. #define PCT1SP_NAME  PCT1SP_NAME_W
  40. #define SSL2SP_NAME  SSL2SP_NAME_W
  41. #define SSL3SP_NAME  SSL3SP_NAME_W
  42.  
  43. #else
  44. #define SSLOLD_NAME  SSLOLD_NAME_A
  45. #define PCTOLD_NAME  PCTOLD_NAME_A
  46. #define UNISP_NAME  UNISP_NAME_A
  47. #define PCT1SP_NAME  PCT1SP_NAME_A
  48. #define SSL2SP_NAME  SSL2SP_NAME_A
  49. #define SSL3SP_NAME  SSL3SP_NAME_A
  50.  
  51. #endif
  52.  
  53. #define SSL2SP_RPC_ID   12
  54. #define PCT1SP_RPC_ID   13
  55. #define SSL3SP_RPC_ID   14
  56. #define UNISP_RPC_ID    15
  57.  
  58.  
  59. #define SCH_CRED_V1      0x00000001
  60. #define SCH_CRED_VERSION 0x00000002
  61.  
  62. #define SCHANNEL_SECRET_TYPE_CAPI       0x00000001
  63. #define SCHANNEL_SECRET_PRIVKEY         0x00000002
  64. #define SCHANNEL_SECRET_TYPE_WINSOCK2   0x00000003
  65.  
  66. #define SCH_CRED_X509_CERTCHAIN   0x00000001
  67. #define SCH_CRED_X509_CAPI        0x00000002
  68. /*
  69.  * WinSock2 Secret Credential
  70.  * Points to a set of callback functions.
  71.  */
  72. typedef struct _SCH_CRED_SECRET_WINSOCK2
  73. {
  74.     DWORD dwType; // SCHANNEL_SECRET_TYPE_WINSOCK2
  75.  
  76.     // Key exchange hook.
  77.     SSLKEYEXCHANGEFUNC pKeyExchangeHookFunc;
  78.     LPVOID pKeyExchangeHookArg;
  79.  
  80.     // Signature hook.
  81.     SSLSIGNATUREFUNC pSignatureHookFunc;
  82.     LPVOID pSignatureHookArg;
  83. } SCH_CRED_SECRET_WINSOCK2, * PSCH_CRED_SECRET_WINSOCK2;
  84.  
  85.  
  86. //
  87. // QueryCredentialsAttribute extensions.
  88. //
  89.  
  90. #define SECPKG_ATTR_SUPPORTED_PROTOCOLS  0x58  // returns SecPkgCred_SupportedProtocols
  91.  
  92. typedef struct _SecPkgCred_SupportedProtocols
  93. {
  94.     DWORD       grbitProtocol;
  95. } SecPkgCred_SupportedProtocols, *PSecPkgCred_SupportedProtocols;
  96.  
  97.  
  98. /*
  99.  * CAPI Secret Credential
  100.  * Points to a pre-initialized Capi Provider handle
  101.  */
  102. typedef struct _SCH_CRED_SECRET_CAPI
  103. {
  104.     DWORD           dwType;      // SCHANNEL_SECRET_TYPE_CAPI
  105.     HCRYPTPROV      hProv;       // credential secret information.
  106.  
  107. } SCH_CRED_SECRET_CAPI, * PSCH_CRED_SECRET_CAPI;
  108.  
  109.  
  110. /*
  111.  * Private Key Secret Credential
  112.  * Contains a potentially encrypted private key in DER
  113.  * format, and a password to crack the key.
  114.  */
  115. typedef struct _SCH_CRED_SECRET_PRIVKEY
  116. {
  117.     DWORD           dwType;       // SCHANNEL_SECRET_PRIVKEY
  118.     PBYTE           pPrivateKey;   // Der encoded private key
  119.     DWORD           cbPrivateKey;
  120.     PSTR            pszPassword;  // Password to crack the private key.
  121.  
  122. } SCH_CRED_SECRET_PRIVKEY, * PSCH_CRED_SECRET_PRIVKEY;
  123.  
  124.  
  125. /*
  126.  * Public Cert Chain Credential
  127.  * DER encoded chain of certificates, with
  128.  * the leaf certificate corresponding to the
  129.  * Secret credential
  130.  */
  131. typedef struct _SCH_CRED_PUBLIC_CERTCHAIN
  132. {
  133.     DWORD       dwType;
  134.     DWORD       cbCertChain;
  135.     PBYTE       pCertChain;
  136. }SCH_CRED_PUBLIC_CERTCHAIN, *PSCH_CRED_PUBLIC_CERTCHAIN;
  137.  
  138. struct _HMAPPER;
  139.  
  140. typedef struct _SCH_CRED
  141. {
  142.     DWORD     dwVersion;          // always SCH_CRED_VERSION.
  143.     DWORD     cCreds;             // Number of credentials.
  144.     PVOID     *paSecret;          // Array of SCH_CRED_SECRET_* pointers
  145.     PVOID     *paPublic;          // Array of SCH_CRED_PUBLIC_* pointers
  146.     DWORD     cMappers;           // Number of credential mappers.
  147.     struct _HMAPPER **aphMappers; // pointer to an array of pointers to credential mappers
  148. } SCH_CRED, * PSCH_CRED;
  149.  
  150.  
  151.  
  152.  
  153. /*
  154.  * QueryContextAttributes extensions
  155.  */
  156.  
  157. #ifndef SECPKG_ATTR_ISSUER_LIST
  158.  
  159. #define SECPKG_ATTR_ISSUER_LIST  0x50
  160. #define SECPKG_ATTR_REMOTE_CRED  0x51
  161.  
  162. typedef struct _SecPkgContext_IssuerListInfo
  163. {
  164.     DWORD   cbIssuerList;
  165.     PBYTE   pIssuerList;
  166. }SecPkgContext_IssuerListInfo, *PSecPkgContext_IssuerListInfo;
  167.  
  168. typedef struct _SecPkgContext_RemoteCredentialInfo
  169. {
  170.     DWORD   cbCertificateChain;     // count of bytes in cert chain buffer.
  171.     PBYTE   pbCertificateChain;     // DER encoded chain of certificates, leaf cert first.
  172.     DWORD   cCertificates;
  173.     DWORD   fFlags;
  174.     DWORD   dwBits;                 // Number of bits in the remote credentials
  175. }SecPkgContext_RemoteCredentialInfo, *PSecPkgContext_RemoteCredentialInfo;
  176.  
  177. #define SecPkgContext_RemoteCredenitalInfo  SecPkgContext_RemoteCredentialInfo
  178. #define PSecPkgContext_RemoteCredenitalInfo PSecPkgContext_RemoteCredentialInfo
  179.  
  180. #endif
  181.  
  182. #define SECPKG_ATTR_LOCAL_CRED   0x52
  183.  
  184. typedef struct _SecPkgContext_LocalCredentialInfo
  185. {
  186.     DWORD   cbCertificateChain;     // count of bytes in cert chain buffer.
  187.     PBYTE   pbCertificateChain;     // DER encoded chain of certificates, leaf cert first.
  188.     DWORD   cCertificates;
  189.     DWORD   fFlags;
  190.     DWORD   dwBits;                 // Number of bits in the remote credentials.
  191. } SecPkgContext_LocalCredentialInfo, *PSecPkgContext_LocalCredentialInfo;
  192.  
  193. #define SecPkgContext_LocalCredenitalInfo  SecPkgContext_LocalCredentialInfo
  194. #define PSecPkgContext_LocalCredenitalInfo PSecPkgContext_LocalCredentialInfo
  195.  
  196.  
  197. // The following two attributes return
  198. // a PCCERT_CONTEXT
  199. #define SECPKG_ATTR_REMOTE_CERT_CONTEXT 0x53
  200. #define SECPKG_ATTR_LOCAL_CERT_CONTEXT  0x54
  201. #define SECPKG_ATTR_ROOT_STORE          0x55 // returns HCERTCONTEXT to the root store
  202.  
  203. typedef struct _PctPublicKey
  204. {
  205.     DWORD Type;
  206.     DWORD cbKey;
  207.     UCHAR pKey[1];
  208. } PctPublicKey;
  209.  
  210. typedef struct _X509Certificate {
  211.     DWORD           Version;
  212.     DWORD           SerialNumber[4];
  213.     ALG_ID          SignatureAlgorithm;
  214.     FILETIME         ValidFrom;
  215.     FILETIME          ValidUntil;
  216.     PSTR            pszIssuer;
  217.     PSTR            pszSubject;
  218.     PctPublicKey    *pPublicKey;
  219. } X509Certificate, * PX509Certificate;
  220.  
  221.  
  222.  
  223. #define RCRED_STATUS_NOCRED          0x00000000
  224. #define RCRED_CRED_EXISTS            0x00000001
  225. #define RCRED_STATUS_UNKNOWN_ISSUER  0x00000002    // The last cert in this chain has
  226.                                                    // an issuer that is unknown to us.
  227.  
  228. #define LCRED_STATUS_NOCRED          0x00000000
  229. #define LCRED_CRED_EXISTS            0x00000001
  230. #define LCRED_STATUS_UNKNOWN_ISSUER  0x00000002    // The last cert in this chain has
  231.                                                    // an issuer that is unknown to us.
  232. //
  233. // QueryContextAttributes extension.
  234. //
  235.  
  236. #define SECPKG_ATTR_CONNECTION_INFO 0x5a // returns SecPkgContext_ConnectionInfo
  237.  
  238. typedef struct _SecPkgContext_ConnectionInfo
  239. {
  240.     DWORD dwProtocol;
  241.     ALG_ID   aiCipher;
  242.     DWORD    dwCipherStrength;
  243.     ALG_ID   aiHash;
  244.     DWORD    dwHashStrength;
  245.     ALG_ID   aiExch;
  246.     DWORD    dwExchStrength;
  247. }SecPkgContext_ConnectionInfo, *PSecPkgContext_ConnectionInfo;
  248.  
  249. //
  250. // MessageId: SEC_I_INCOMPLETE_CREDENTIALS
  251. //
  252. // MessageText:
  253. //
  254. //  If this is returned from InitializeSecurityContext, it indicates
  255. //  that the credentials supplied were incomplete, and client-auth was
  256. //  attempted.  On receipt, the client should call QueryContextAttributes
  257. //  with SECPKG_ATTR_LOCAL_CERT to get the cert that was negotiated,
  258. //  and the supply the private key with this cert to AcquireCredential
  259. //  to get a new credential.  The context should then be closed,
  260. //  and renegotiation should be completed.
  261. //
  262. //
  263. #define SEC_I_INCOMPLETE_CREDENTIALS      ((HRESULT)0x00090320L)
  264.  
  265. #define SEC_E_INCOMPLETE_CREDENTIALS      ((HRESULT)0x80090320L)
  266.  
  267.  
  268. //
  269. // MessageId: SEC_I_RENEGOTIATE
  270. //
  271. // MessageText:
  272. //
  273. // This is returned by UnsealMessage, and indicates that the app should
  274. // restart the renegotiation loop.  It should use the existing context, and
  275. // pass in no data in the input buffers for the first call to AcceptSecurityContext
  276. // or InitializeSecurityContext.
  277. //
  278. #define SEC_I_RENEGOTIATE            ((HRESULT)0x00090321L)
  279.  
  280.  
  281.  
  282. #define NETWORK_DREP    0x00000000
  283.  
  284.  
  285.  
  286. // Structures for compatability with the old
  287. // SCHANNEL cred interface.
  288.  
  289. typedef struct _SSL_CREDENTIAL_CERTIFICATE {
  290.     DWORD   cbPrivateKey;
  291.     PBYTE   pPrivateKey;
  292.     DWORD   cbCertificate;
  293.     PBYTE   pCertificate;
  294.     PSTR    pszPassword;
  295. } SSL_CREDENTIAL_CERTIFICATE, * PSSL_CREDENTIAL_CERTIFICATE;
  296.  
  297.  
  298.  
  299. BOOL
  300. WINAPI
  301. SslGenerateKeyPair(
  302.     PSSL_CREDENTIAL_CERTIFICATE pCerts,
  303.     PSTR pszDN,
  304.     PSTR pszPassword,
  305.     DWORD Bits );
  306.  
  307.  
  308. VOID
  309. WINAPI
  310. SslGenerateRandomBits(
  311.     PUCHAR      pRandomData,
  312.     LONG        cRandomData
  313.     );
  314.  
  315.  
  316. BOOL
  317. WINAPI
  318. SslCrackCertificate(
  319.     PUCHAR              pbCertificate,
  320.     DWORD               cbCertificate,
  321.     DWORD               dwFlags,
  322.     PX509Certificate *  ppCertificate
  323.     );
  324.  
  325.  
  326. VOID
  327. WINAPI
  328. SslFreeCertificate(
  329.     PX509Certificate    pCertificate
  330.     );
  331.  
  332. BOOL
  333. WINAPI
  334. SslGetDefaultIssuers(
  335.     PBYTE pbIssuers,
  336.     DWORD *pcbIssuers);
  337.  
  338. #define SSL_CRACK_CERTIFICATE_NAME  TEXT("SslCrackCertificate")
  339. #define SSL_FREE_CERTIFICATE_NAME   TEXT("SslFreeCertificate")
  340.  
  341. typedef BOOL
  342. (WINAPI * SSL_CRACK_CERTIFICATE_FN)
  343. (
  344.     PUCHAR              pbCertificate,
  345.     DWORD               cbCertificate,
  346.     BOOL                VerifySignature,
  347.     PX509Certificate *  ppCertificate
  348. );
  349.  
  350.  
  351. typedef VOID
  352. (WINAPI * SSL_FREE_CERTIFICATE_FN)
  353. (
  354.     PX509Certificate    pCertificate
  355. );
  356.  
  357. #define SSL_SET_PROTOCOLS_NAME TEXT("SslSetProtocols")
  358. #define SSL_GET_PROTOCOLS_NAME TEXT("SslGetProtocols")
  359.  
  360. typedef BOOL
  361. (WINAPI * SSL_SET_PROTOCOLS_FN)(
  362.     DWORD rgbitsProtocols
  363.     );
  364.  
  365. typedef DWORD
  366. (WINAPI * SSL_GET_PROTOCOLS_FN)();
  367.  
  368. BOOL
  369. WINAPI
  370. SslSetProtocols(
  371.     DWORD rgbitsProtocols
  372.     );
  373.  
  374. DWORD
  375. WINAPI
  376. SslGetProtocols();
  377.  
  378. #endif //__SCHNLSP_H__
  379.